# -*- coding: utf-8 -*-

# setup.py
# Part of ‘manpage’, a Python library for making Unix manual documents.
#
# Copyright © 2008–2016 Ben Finney <ben+python@benfinney.id.au>
#
# This is free software: see the grant of license at end of this file.

""" Distribution setup for ‘manpage’ library. """

import os
import os.path
import pydoc
import email.utils
from types import SimpleNamespace

import setuptools.command.test
from setuptools import (setup, find_packages)


setup_dir = os.path.dirname(__file__)

changelog = SimpleNamespace()
changelog.package = "manpage"
changelog.version = "0.1"
changelog.author = "Ben Finney <ben+python@benfinney.id.au>"
(author_name, author_email) = email.utils.parseaddr(changelog.author)

control_structure = dict()
control_structure['maintainer'] = changelog.author
(maintainer_name, maintainer_email) = email.utils.parseaddr(
        control_structure['maintainer'])
control_structure['homepage'] = "https://notabug.org/bignose/python-manpage"

copyright_structure = SimpleNamespace()
license = SimpleNamespace()
license.synopsis = "GPLv3+"
copyright_structure.license = license

main_module = __import__(changelog.package)
(synopsis, long_description) = pydoc.splitdoc(pydoc.getdoc(main_module))


class TestDiscoverCommand(setuptools.command.test.test):
    """ Setuptools `test` command explicitly using test discovery. """

    def _test_args(self):
        yield 'discover'
        for arg in super()._test_args():
            yield arg


setup(
        name=changelog.package,
        version=str(changelog.version),
        packages=find_packages(exclude=["tests"]),

        # Setuptools metadata.
        maintainer=maintainer_name,
        maintainer_email=maintainer_email,
        zip_safe=False,
        install_requires=[
            "setuptools",
            ],
        test_suite="tests",
        cmdclass={
            'test': TestDiscoverCommand,
            },

        # PyPI metadata.
        author=author_name,
        author_email=author_email,
        description=synopsis,
        license=license.synopsis,
        keywords="manpage manual man page".split(),
        url=control_structure['homepage'],
        long_description=long_description,
        classifiers=[
            # Reference: https://pypi.python.org/pypi?:action=list_classifiers
            "Development Status :: 4 - Beta",
            " :: ".join([
                "License :: OSI Approved",
                "GNU General Public License v3 or later (GPLv3+)"]),
            "Operating System :: POSIX",
            "Programming Language :: Python :: 3",
            "Programming Language :: Python :: 3.3",
            "Programming Language :: Python :: 3.4",
            "Programming Language :: Python :: 3.5",
            "Intended Audience :: Developers",
            "Topic :: Documentation",
            ],
        )


# This is free software: you may copy, modify, and/or distribute this work
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; version 3 of that license or any later version.
#
# No warranty expressed or implied. See the file ‘LICENSE.GPL-3’ for details,
# or view it online at <URL:https://www.gnu.org/licenses/gpl-3.0.html>.


# Local variables:
# coding: utf-8
# mode: python
# End:
# vim: fileencoding=utf-8 filetype=python :
